home *** CD-ROM | disk | FTP | other *** search
/ Aminet 4 / Aminet 4 - November 1994.iso / aminet / comm / term / vltfonebook.lha / VLTFoneBook / VLTDialer.rexx < prev    next >
OS/2 REXX Batch file  |  1993-07-29  |  2KB  |  78 lines

  1. /***************************************************************************** 
  2. *** VLTDialer.rexx
  3. ***   dial a phone number inside vlt
  4. *****************************************************************************/
  5.  
  6. /**  Hayes modem responses  **/
  7. response     = "OK"
  8. connectstr   = "CONNECT"
  9. busystr      = "BUSY"
  10. nocarrierstr = "NO CARRIER"
  11. DialStr      = "ATDT"               /* hayes modem dial prefix              */
  12.  
  13. /**  simple hangup script (drop DTR)  **/
  14. hangupscript = "hangup"
  15.  
  16. /**  set the port to that of this invocation of VLT  **/
  17. parse arg vltport ',' name ',' phone baud parity script
  18. address value vltport
  19.  
  20. /**  '-' in script field means no script  **/
  21. script = strip(script)
  22. if script = "-" then script = ""
  23.  
  24. /**  Check if set up correctly without requesters coming up.  **/
  25. call pragma('W', 'NULL')
  26.  
  27. /**  Dialing procedure follows                                  **/
  28. /**  Preset the cancel flag to something, set baud and parity.  **/
  29. vlt.CANCELFLAG = "start"
  30. if length(baud)   > 0 then "baud   "baud
  31. if length(parity) > 0 then "parity "parity
  32.  
  33. /** try until connect **/
  34. do forever
  35.  
  36. /**  Set up the "CONNECT" trap. **/
  37.  
  38. /**  Set up the OK, CONNECT, BUSY and NO CARRIER traps. **/
  39. "trap add 314 install ("connectstr")   (cancel $vltphone_wait "connect")"
  40. "trap add 315 install ("busystr")      (cancel $vltphone_wait "busy")"
  41. "trap add 316 install ("nocarrierstr") (cancel $vltphone_wait "nocarrier")"
  42.  
  43. /**  Send dial string and wait until the "pause" gets cancelled  **/
  44. if length(phone) > 0 then do
  45.   "move 1 1; emit (Dialing"name"...); move 1 2"
  46.   "$vltphone_wait: send ("DialStr||phone"*r); pause"
  47. end
  48. else do
  49.   "message (please give a phone number.)"
  50.   exit
  51. end
  52.  
  53. /**  We got cancelled. See which event cancelled us.  **/
  54. event = vlt.CANCELFLAG
  55.  
  56. /**  Remove the traps but only the ones we used.  **/
  57. "trap remove 313 314 315 316"
  58.  
  59. /**  If we got connected, close the panel if it exists **/
  60. if upper(event) = "CONNECT" then do
  61.   if showlist('p', VLTPHONEBOOK) ~= 0 then do
  62.     "message"
  63.     address VLTPHONEBOOK quit
  64.   end
  65.   if script ~= "" then "@@VLTFoneBook:"script
  66.   exit(0)
  67. end
  68.  
  69. /**  Check if we got an abort event. If so, quit.  **/
  70. if upper(event) = "ABORT" then do
  71.   "message (Aborted!)"
  72.   exit(0)
  73. end
  74.  
  75. end
  76. /** end **/
  77.  
  78.